<?
if(isset($_GET['file']))
{
	$Folder=base64_decode($_GET['folder']);
	$ViewFile=base64_decode($_GET['file']);
	$path=$Folder.'/'.$ViewFile;
	$path=str_replace("//","/",$path);
	//echo $path;
	echo  ViewFile($path,200,200);
}

function ViewFile($path,$width="",$height="",$Option="")
{
	$str="";
	$ptemp="../".$path;
	$properties=pathinfo($ptemp); 
	if (!isset($properties['extension'])) $properties['extension']="";
	$type=strtolower($properties['extension']);
	if($type=="gif"||$type=="jpg"||$type=="jpeg"||$type=="png"||$type=="bmp") $str=DisplayImage($path,$width,$height,$Option);
	if($type=="swf"||$type=="swc") $str=DisplayFlash($path,$width,$height);
	if($type=="wmv"||$type=="avi"||$type=="dat"||$type=="mp2"||$type=="mp3") $str=DisplayMedia($path,$width,$height);
	return $str;
}

function DisplayImage($imPath,$showWidth="",$showHeight="",$imgOption="")
{
	$srcImg="";
	$imgsize = @getimagesize("../".$imPath);
	if($imgsize[2]==1||$imgsize[2]==2||$imgsize[2]==6)
	{
		$rWidth="";$rHeight="";
		$sWidthHeight="";
		if($showWidth!=""&&$showHeight!="")
		{
			$rWidth=$imgsize[0]/$showWidth;
			$rHeight=$imgsize[1]/$showHeight;
			$rWidth>$rHeight?$ratioImg=$rWidth:$ratioImg=$rHeight;
			$sWidthHeight=" width=\"".round($imgsize[0]/$ratioImg)."\" height=\"".round($imgsize[1]/$ratioImg)."\"";
		}else
		{
			if($showWidth=="") $sWidthHeight=" height=\"$showHeight\"";
			if($showHeight=="") $sWidthHeight=" width=\"$showWidth\"";
		}
		$srcImg="<img src=\"$imPath\" ".$sWidthHeight." ".$imgOption.">";
	}
	return $srcImg;
}

function DisplayFlash($flPath,$showWidth="",$showHeight="")
{
	if($showWidth=="")	$showWidth="100%";
	if($showHeight=="")	$showHeight="100%";
	$Temp="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=  \"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"$showWidth\" height=\"$showHeight\">
      <param name=\"movie\" value=\"$flPath\" />
      <param name=\"quality\" value=\"high\" />
      <embed src=\"$flPath\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"$showWidth\" height=\"$showHeight\"></embed>
    </object>";
	return $Temp;
}

function DisplayMedia($mPath,$showWidth="",$showHeight="")
{
	if($showWidth=="")	$showWidth="100%";
	if($showHeight=="")	$showHeight="100%";
	$Temp='<OBJECT id=Player codeBase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 height="'.$showHeight.'" width="'.$showWidth.'" classid=clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6>';
	$Temp.='<PARAM name="URL" value="'.$mPath.'">';
	$Temp.='<PARAM NAME="AutoStart" Value="true">';
	$Temp.='<PARAM NAME="TransparentAtStart" Value="true">';
	$Temp.='<PARAM NAME="backgroundColor" VALUE="#000000">';
	$Temp.='<PARAM NAME="stretchToFit" VALUE="true">';
	$Temp.='<PARAM NAME="volume" VALUE="100">';
	$Temp.='<embed name="PlayerMoz" type="application/x-mplayer2" height="'.$showHeight.'" width="'.$showWidth.'"></embed>
	</OBJECT>';
	return $Temp;
}
?>